{% extends "house/base.html" %}
{% block title %}{% endblock %}
{% block content_title %}{% endblock %}


{% block sub_menu %}
<li><a href="{% url prev_month %}">Предыдущий месяц</a></li>
<li><a href="{% url current_month %}">Текущий месяц</a></li>
<li><a href="{% url next_month %}">Следующий месяц</a></li>
<li><a href="{% url debtor %}">Неплательщики</a></li>
{% endblock %} 

{% block mainmenuitem_1 %}class="mainMenuSelectedItem"{% endblock %}

{% block main %}


{% comment %} 
<script language="JavaScript">
<!--

function checkForm(obj) {
  if(obj.cash.value == "")
  {
    return false;
  }
  return true;
}

function setCash(sum, id){
  var form = document.getElementById(id);
  
  if(form.cash.value == "")
  {
    form.cash.value = sum;
  }
  else
  {
    form.cash.value = parseInt(form.cash.value) + parseInt(sum);
  }
  return false;
}
-->
</script>
{% endcomment %}


<h2>{{processed_month_verbose}} {{processed_year}} г.</h2>

{% comment %}
<a href="{{prev_month_year_link}}">Предыдущий месяц</a> | 
<a href="{{next_month_year_link}}">Следующий месяц</a>
{% endcomment %}

<div class="floats">

<table>
  <tr>
    <th width="10%">Кв. №</th>
    <th width="15%">Сумма</th>
    <th width="1%"></th>
    <th width="23%"></th>
    <th width="30%">Конт. лицо</th>
    <th width="20%">Номер тел.</th>
    <th width="1%"></th>
  </tr>
  {% for apartment in apartment_list %}
  <tr>
    <td>{{ apartment.number }}</td>
    <td>
      {% if apartment.summ != 0 %}
        {{ apartment.summ }} р.
      {% endif %}
      {% if not apartment.cashed and apartment.payment_summ %}
        <nobr><font color="brown"> / {{ apartment.payment_summ }} р.</font></nobr>
      {% endif %}
    </td>
    <td>
      {% if apartment.summ != 0 %}
        {% if not apartment.cashed %}
          <img src="{% load media %}{% media_prefix %}img/house-into.gif" width="14" height="14" alt="по умолчанию" 
          OnClick="setCash('{{ apartment.summ }}', 'form_id_{{ apartment.id }}');"
          style="cursor:pointer; cursor: hand;">
        {% endif %}
      {% endif %} 
    </td>
    <td>
    {% if apartment.summ == 0 %}
      <Font color="red">Не платят</Font>
    {% else %}
      {% if not apartment.cashed %}
      <nobr>
      <form name="form_name_{{ apartment.id }}" method="post" action="." 
        onsubmit="return checkForm(this, 'Зачислить в '+'{{ apartment.number }} квартиру ');" id="form_id_{{ apartment.id }}">
        <input name="cash" type="text" size="5"/>
        <input name="id" type="hidden" value="{{ apartment.id }}"/>
        <input type="submit" value="Зачислить"/>
      </form>
      </nobr>
      {% else %}
        <nobr><Font color="green">Оплачено: {{ apartment.cashed_date|date:"d.m.Y" }}</Font></nobr>
      {% endif %}
    {% endif %} 
    </td>
    <td>{{ apartment.contact_person }}</td>
    <td>{{ apartment.phone }}</td>
    <td><a href="{% url apartment_property apartment.id %}" title="Редактирование данных квартиры"><img src="{% media_prefix %}img/house-edit.gif" width="14" height="14" alt="свойства"></a>    </td>
  </tr>   
  {% endfor %} 
</table>
   
</div>

{% endblock %}
